﻿<?php
	session_start();
	$title="Quản lý bài viết";
		require_once '../layout/headeradmin.inc';
	if($_SESSION['username']!=null)
	{
		require_once('../lib/Modelsphp.php');
		$k=new Modelsphp();
		$db=$k->getlistArticle();
		
		?>
		<script>
$(document).ready(function(){
	$("#user .checkin input:checkbox").change(function(){
		if($(this).is(":checked"))
		{
			$.get("checked.php?checkin=them&id="+$(this).val());
		}
		else
		{
			$.get("checked.php?checkin=xoa&id="+$(this).val());
		}
	});
	$("#user .active input:checkbox").change(function(){
		if($(this).is(":checked"))
		{
			$.get("checked.php?active=them&id="+$(this).val());
		}
		else
		{
			$.get("checked.php?active=xoa&id="+$(this).val());
		}
	});
});
</script>
		
		<div id="menu-main">
    <a href="createUser.php"> <input type="button" value="Thêm Người dùng" class="button_cre"> </a>
    <input type="button" value="Thêm Người dùng" class="button_cre"> 
  
      
</div>
     
    <fieldset>
        <legend><text>Danh sách người dùng</text></legend>
        <table id="user">
            <thead>
                <tr>
                  <!--  <td><input type="checkbox" name="chkall" id="chkall" /></td> -->
                    <td>Tiêu đề</td>
                   <td>Checkin</td>
                    <td>Hoạt động</td>
                  
                     <td>Thao tác</td>
					 
                </tr>
            </thead>
            <tbody>
                <?php
                

                $i=0;
                while ($row = mysqli_fetch_array($db))
                {
                    
                   if(($i%2)==0)
                   {
                       echo'<tr class="odd">';
                   }
                    else {
                      echo '<tr>';
                    }
                        
                        ?>                
                        
                         <!--   <td><input type="checkbox" class="chkall" /></td>-->
                            <td><?php echo $row['title']; ?></td>
                            <td  class="checkin"> <input type="checkbox" <?php if($row['checkin']=='1') echo ' checked';?> value="<?php echo $row['id']; ?>" >  </td>
   
                           
                            <td  class="active"><input type="checkbox" <?php if($row['Active']=='1') echo ' checked'; ?> value="<?php echo $row['id']; ?>" >  </td>
                            <td><a href="editUser.php?ac=user&id=<?php echo $row['id']; ?>">Sửa</a>-<a href="Delete.php?ac=user&id=<?php echo $row['id']; ?>">Xóa</a></td>
        </tr>             

                        <?php
                        $i++;
                }
                ?>
            </tbody>
            <tfoot>
                <tr>
                    <td> <p>Phân trang</p></td>
            </tr>
            </tfoot>
        </table>
        
    </fieldset>
</div>

	<style>
	.active
	{
	}
</style>	
		
		
		
		
		
		
		<?php
		
require '../layout/footeradmin.inc';
	}
	else
	{
		header('Location:index.php');
	}
?>